home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12240 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: strncpy bug?
  5. Date: Fri, 29 Mar 96 23:20:35 GMT
  6. Organization: none
  7. Message-ID: <828141635snz@genesis.demon.co.uk>
  8. References: <ccurtis.826776589@ee.fit.edu> <4iffqt$gu4@hammy.lonestar.org>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4iffqt$gu4@hammy.lonestar.org>
  15.            gordon@sneaky.lerctr.org "Gordon Burditt" writes:
  16.  
  17. >There are a few ANSI C library functions that permit passing NULL
  18. >where a pointer is expected.  Very few.  If it's not documented
  19. >as OK, you invoke the wrath of undefined behavior.  A NULL pointer
  20. >does not meet the definition of a "string".  I think this is a complete
  21. >list of ANSI C functions that accept NULL pointers, but I might have 
  22. >missed a couple:
  23. >
  24. >(FILE *) NULL
  25. >        fflush(NULL) flushes all streams.
  26.  
  27. Well, all streams for which fflush() is defined i.e. output streams and
  28. update streams where the last operation was a write.
  29.  
  30. >(time_t *) NULL
  31. >        time(NULL) doesn't store a copy through its first argument
  32. >        in addition to the return value.
  33. >(void *) NULL
  34. >        printf family, NULL argument matching a %p conversion may be printed.
  35.  
  36. But make sure the argument you pass really is a (void *).
  37.  
  38. >        free(NULL) does nothing.
  39. >        realloc(NULL, size) acts like malloc(size).
  40. >(char **) NULL
  41. >        The 2nd argument of strtod, strtol, and strtoul may be NULL to
  42. >        omit returning the pointer to the next character after the converted
  43. >        number.
  44. >(char *) NULL (strings)
  45. >        strtok (1st argument) NULL indicates continuing to use a
  46. >        previously passed string.
  47. >        strxfrm may have a NULL 1st argument if the length is 0.
  48. >        system(NULL) is used to test whether the facility is available.
  49. >(char *) NULL (buffer)
  50. >        setbuf and setvbuf(2nd argument) NULL indicates unbuffered operation.
  51.  
  52. Only in setbuf(). In setvbuf() a NULL 2nd argument makes the function
  53. allocate a buffer internally (where appropriate).
  54.  
  55. >(char *) NULL multibyte character functions
  56. >        mblen (1st arg), mbtowc (2nd arg), and wctomb(1st arg) accept
  57. >        NULL for certain special cases.
  58.  
  59. -- 
  60. -----------------------------------------
  61. Lawrence Kirby | fred@genesis.demon.co.uk
  62. Wilts, England | 70734.126@compuserve.com
  63. -----------------------------------------
  64.